package com.liang.blog.service;

import com.liang.blog.mapper.BlogInfoMapper;
import com.liang.blog.model.BlogInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Service
public class BlogService {
    @Autowired
    private BlogInfoMapper blogInfoMapper;
    public List<BlogInfo> getList() {
        return  blogInfoMapper.selectAll();
    }
    @RequestMapping("/getBlogDetail")
    public BlogInfo getBlogDetail(Integer blogId) {
//        return blogInfoMapper.selectAllInfoById(blogId);
        return blogInfoMapper.selectById(blogId);
    }
   //发布博客
    public Integer insertBlog(BlogInfo blogInfo) {
        return blogInfoMapper.insertBlog(blogInfo);
    }

    public Integer update(BlogInfo blogInfo) {
        return blogInfoMapper.updateBlog(blogInfo);
    }
   @GetMapping("/selectCountById")
    public Long selectCountById(Integer id) {
        return blogInfoMapper.selectCountById(id);
    }

    @GetMapping("/selectKindById")
    public Long selectKindById(Integer id) {
        return blogInfoMapper.selectKindById(id);
    }

    @GetMapping("/selectByTitleKey")
    public List<BlogInfo> selectByTitleKey(String titleKey) {
        return blogInfoMapper.selectByTitleKey(titleKey);
    }
}
